Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor IsRefreshing property to separate animation and command execution responsibilities #15732

Closed
wants to merge 7 commits into from

Conversation

japarson
Copy link
Contributor

@japarson japarson commented Jun 19, 2023

Description of Change

This pull request proposes a modification to the behavior of the RefreshView control.

Currently, setting the IsRefreshing property to true in the RefreshView control not only enables the loading animation but also triggers the associated command.

To address this issue, the proposed change involves separating the responsibilities of the IsRefreshing property to achieve the desired behavior:

  1. IsRefreshing will solely control the animation enable/disable feature.
  2. Command execution will only be executed when the user initiates the refresh through the control UI or at their discretion within their view model.

But why is separating the responsibilities necessary?

As @janseris notes,

We could set IsRefreshing=true in the ViewModel instead of calling ReloadData to achieve the correct behavior but that is not a good idea because we cannot assume from the ViewModel that setting property IsRefreshing will call the ReloadData method by coincidence (we don't know in ViewModel that IsRefreshing is bound to a RefreshView control in the View which also by coincidence calls ReloadData via a registered Command).

We could possibly rename the IsRefreshing property to better reflect its behavior, but this would create a breaking change. Some possibilities would be:

  1. IsAnimating
  2. IsAnimationInProgress
  3. IsRefreshingAnimationActive
  4. IsRefreshAnimationVisible

If this change is accepted, I will also update the documentation which states:

Manually setting the IsRefreshing property to true will trigger the refresh visualization, and will execute the ICommand defined by the Command property.

Source: learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/refreshview?view=net-maui-7.0

Issues Fixed

Fixes #6456
Fixes #1171

@ghost ghost added the community ✨ Community Contribution label Jun 19, 2023
@ghost
Copy link

ghost commented Jun 19, 2023

Hey there @japarson! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@japarson japarson changed the title Add Command and CommandParameter to IRefreshView Refactor IsRefreshing property to separate animation and command execution responsibilities Jun 19, 2023
@PureWeen
Copy link
Member

The initial spec called for a visualization property

public static readonly BindableProperty VisualizationStateProperty;
	public RefreshVisualizationState VisualizationState { get; set; }

public enum RefreshVisualizationState
{
	Idle,
	Active
}

Could we use that instead of causing breaking changes?

/// <summary>
/// Gets the command to be executed when the refresh is triggered.
/// </summary>
ICommand Command { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to pull ICommand into core for this. This can instead be something like void UserRefreshing and the commanding is all handled in controls.

Similar to IButton

public interface IButton : IView, IPadding, IButtonStroke

@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Jun 22, 2023
@PureWeen PureWeen removed the community ✨ Community Contribution label Jun 28, 2023
@jsuarezruiz
Copy link
Contributor

@japarson Could you rebase to fix the conflicts?. Let me know if you need help with anything.

@PureWeen PureWeen marked this pull request as draft July 6, 2023 19:46
@japarson
Copy link
Contributor Author

We will review the overall design of the RefreshView control in the .NET 9 timeline.

@japarson japarson closed this Jul 10, 2023
@janseris
Copy link

We will review the overall design of the RefreshView control in the .NET 9 timeline.

What about NET 8? NET 9 is really far away. You should really reconsider the change for this year.

@japarson
Copy link
Contributor Author

We will review the overall design of the RefreshView control in the .NET 9 timeline.

What about NET 8? NET 9 is really far away. You should really reconsider the change for this year.

The plan is to only document a workaround for #6456 right now. In the future, we will fix the issue as part of a larger set of improvements to the RefreshView control. Unfortunately, we don't have the time/resources to implement these improvements for .NET 8. I'll publish the workaround on the original issue soon - please let me know if it's not valid.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RefreshView executes command on Page loading [Enhancement] Fix the RefreshView implementation
5 participants